//
//  WHBaseViewController.swift
//  WHSinaWeiBo
//
//  Created by 王寒 on 16/4/8.
//  Copyright © 2016年 wanghan. All rights reserved.
//

import UIKit

class WHBaseViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

 
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        
        var title = "返回"
        if childViewControllers.count == 1{
            title = "首页"
        }
        
        if childViewControllers.count > 0{
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: title, target: self, action: "pop")
            viewController.hidesBottomBarWhenPushed = true
            viewController.view.backgroundColor = UIColor.whiteColor()
        }
        
        
        super.pushViewController(viewController, animated: animated)
    }
    
    
    @objc private func pop(){
        popViewControllerAnimated(true)
    }

}
